﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using YArchitech.BIM;
using YArchitech.Controls;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;

namespace YArchitech.HYSpace
{
	public partial class FrmModifyTimeName : System.Windows.Forms.Form
	{
		public FrmModifyTimeName()
		{
			this.InitializeComponent();
			base.Icon = Resource.YArchitechIcon;
		}

		public FrmModifyTimeName(string timeFileName)
		{
			this.InitializeComponent();
			base.Icon = Resource.YArchitechIcon;
			foreach (TimeAssign timeAssign in FrmTimeAssignManage.listTimeAssign)
			{
				if (timeAssign.Id.ToString() == timeFileName)
				{
					this.tAssign = timeAssign;
					if (this.tAssign.Operation != "添加")
					{
						this.tAssign.Operation = "修改";
					}
				}
			}
		}

		private void FrmModifyTimeName_Load(object sender, EventArgs e)
		{
			this.txtTimeType.Text = this.tAssign.TsParent;
			int num = this.tAssign.TsName.IndexOf("_");
			this.txtTimeName.Text = this.tAssign.TsName.Substring(num + 1);
		}

		private void btnCancle_Click(object sender, EventArgs e)
		{
			base.Close();
		}

		private void btnSure_Click(object sender, EventArgs e)
		{
			if (string.IsNullOrEmpty(this.txtTimeName.Text))
			{
				this.txtTimeName.Focus();
				return;
			}
			string text = this.tAssign.TsParent + "_" + this.txtTimeName.Text.Trim();
			bool flag = false;
			IEnumerator<TimeAssign> enumerator = FrmTimeAssignManage.listTimeAssign.GetEnumerator();
			{
				while (enumerator.MoveNext())
				{
					if (enumerator.Current.TsName == text)
					{
						YJKMessageBox.Show("时间表不能重名");
						flag = true;
						break;
					}
				}
			}
			if (flag)
			{
				this.txtTimeName.SelectAll();
				this.txtTimeName.Focus();
				return;
			}
			this.tAssign.TsName = text;
			base.DialogResult = DialogResult.Yes;
		}

		public TimeAssign tAssign = new TimeAssign();
	}
}
